class CanvasWindow extends ElementWindow {
    
  CanvasWindow(Element element)
  {
    this.element = element;
  }
  
  void draw(){

    context.clearRect(0,0,width,height);
    for(ElementWindow child in children)
    {
      child.draw();
    }
    
    CanvasWindow parentCanvas = getParentCanvas();
    if(parentCanvas != null)
    {
      parentCanvas.context.drawImage(this.element, getX(), getY());
    }
  }
  
  CanvasElement get canvas()
  {
    return element;
  }
  
  CanvasRenderingContext2D get context()
  {
    return canvas.getContext('2d');
  }
}

